package com.monkey.servicepassengeruser.controller;

import com.monkey.internalcommon.dto.ResponseResult;
import com.monkey.internalcommon.request.VerificationCodeDTO;
import com.monkey.servicepassengeruser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author tao
 * @date 2022/6/15 23:05
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/user")
    public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO) {

        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        System.out.println("手机号：" + passengerPhone);
        userService.loginOrRegister(passengerPhone);
        return ResponseResult.success();
    }

    @GetMapping("/user/{phone}")
    public ResponseResult getUser(@PathVariable("phone") String passenger) {
        return userService.getUserByPhone(passenger);
    }
}
